﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="acpIncluirFrotaClassificacao.aspx.cs" Inherits="Protegidos_Administracao_Cadastros__popup_acpIncluirFrotaClassificacao" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajax" %>
<%@ Register TagPrefix="uc1" TagName="HeadTag"  Src="~/_includes/HeadTag.ascx" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <!-- Includes -->
    <uc1:HeadTag ID="HeadTag1" runat="server" />        
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
        <telerik:RadProgressManager ID="RadProgressManager1" runat="server" />
        <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
        <script type="text/javascript">
            function CloseAndRebind(args)
            {
                GetRadWindow().Close();
                GetRadWindow().BrowserWindow.refreshGrid(args);
            }
    		
            function GetRadWindow()
            {
                var oWindow = null;
                if (window.radWindow) oWindow = window.radWindow; //Will work in Moz in all cases, including clasic dialog
                else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;//IE (and Moz as well)
    				
                return oWindow;
            }

            function CancelEdit()
            {
                GetRadWindow().Close();
            }

            /* <![CDATA[ */

            function StopPropagation(e) {
                //cancel bubbling
                e.cancelBubble = true;
                if (e.stopPropagation) {
                    e.stopPropagation();
                }
            }

            function onDropDownClosing() {
                cancelDropDownClosing = false;
            }

            function onCheckBoxClick(chk) {
                var combo = $find("<%= rcbCategoriaCNH.ClientID %>");
                //prevent second combo from closing
                cancelDropDownClosing = true;
                //holds the text of all checked items
                var text = "";
                //holds the values of all checked items
                var values = "";
                //get the collection of all items
                var items = combo.get_items();

                //enumerate all items
                for (var i = 0; i < items.get_count(); i++) {
                    var item = items.getItem(i);
                    //get the checkbox element of the current item
                    var chk1 = $get(combo.get_id() + "_i" + i + "_chk1");
                    if (chk1.checked) {
                        text += item.get_text() + ",";
                        values += item.get_value() + ",";
                    }
                }
                //remove the last comma from the string
                text = removeLastComma(text);
                values = removeLastComma(values);

                if (text.length > 0) {
                    //set the text of the combobox
                    combo.set_text(text);
                }
                else {
                    //all checkboxes are unchecked
                    //so reset the controls        
                    combo.set_text("")
                }
            }

            //this method removes the ending comma from a string
            function removeLastComma(str) {
                return str.replace(/,$/, "");
            }

            /* ]]> */            
        </script>
        </telerik:RadCodeBlock>
        
        <table width="99%" align="right">
            <tr id="trTitulo" runat="server">
                <td>
                    <div class="SuTituloVR">Classificação</div>
                </td>
            </tr>
            
            <tr id="trMensagem" runat="server" visible="false">
                <td valign="middle" style="background-color:#FFFFAA; height:33px">
                    &nbsp;&nbsp;<asp:Label ID="lblResultado" runat="server" Text="" Font-Names="Verdana" Font-Size="9"></asp:Label>
                </td>
            </tr>  
            
            <tr>
                <td>
                    <table>
                        <tr id="trClassificacao" runat="server">
                            <td style="width: 200px"><span class="textoCZ_12">Classificação:</span></td>
                            <td><asp:TextBox ID="txtClassificacao" runat="server" Text="" Width="240px" MaxLength="300"></asp:TextBox></td>
                        </tr>
                        <tr id="trCategoriaCNH" runat="server">
                            <td style="width: 200px"><span class="textoCZ_12">Categoria de Habilitação:</span></td>
                            <td>
                                <telerik:RadComboBox ID="rcbCategoriaCNH" runat="server" Skin="Telerik" DataTextField="Categoria" 
                                        DataValueField="IdCategoriaCNH" Font-Names="Verdana" EmptyMessage="Selecione uma opção" HighlightTemplatedItems="true"
                                        AllowCustomText="true" Width="240px" OnClientDropDownClosed="onDropDownClosing">
                                    <ItemTemplate>
                                        <div onclick="StopPropagation(event)">
                                            <asp:CheckBox runat="server" ID="chk1" Checked="true" onclick="onCheckBoxClick(this)" />
                                            <asp:Label runat="server" ID="lblDescricao" AssociatedControlID="chk1"><%# Eval("Categoria")%></asp:Label>
                                        </div> 
                                    </ItemTemplate>
                                </telerik:RadComboBox>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            
            <tr>
                <td align="right">
                <br />
                    <asp:Button ID="btnGravar" runat="server" Text="Gravar" Width="110px" onclick="btnGravar_Click" />&nbsp;&nbsp;
                    <asp:Button ID="btnFechar" runat="server" Text="Fechar" Width="110px" onclick="btnFechar_Click" />
                </td>
            </tr>
        </table>
    </form>
</body>
</html>
